﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UBlockly.Compotent;
using UBlockly.Scriptable;

namespace UBlockly.UI
{
    public abstract class BranchNode : Node, IBranchNode
    {
        public abstract bool IsNullBranch { get; }
        public abstract int BranchCount { get; }
        public Node Node => this;
        public BranchNode(BlockObject block, NodeScriptable x) : base(block, x) { }

        public abstract LinkedList<Node> GetBranch(int id);

        public abstract Node GetBranchRoot(int id);

        public void CreateBranchRoot(int branchId, EmptyScriptNode rootNode)
        {         
            GetBranch(branchId).AddFirst(rootNode);
            rootNode.BodyChangeNotify = AnyBranchChangeNotify;
        }

        public void AnyBranchChangeNotify()
        {
            Debug.LogError("有分支发生改变");
            Block.ReSize();
            (Block.Node.List as ULinkedList<Node>).DoNotify();
        }
        
    }
}
